<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>hma_start</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            >hma_start</th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        Module&nbsp;hma_start
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="hma_start-module.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== MODULE DESCRIPTION ==================== -->
<h1 class="epydoc">Module hma_start</h1><p class="nomargin-top"><span class="codelink"><a href="hma_start-pysrc.html">source&nbsp;code</a></span></p>
<hr />
<div class="fields">      <p><strong>Since:</strong>
        Jan 2, 2012
      </p>
      <p><strong>Author:</strong>
        Chris Giacofei
      </p>
      <p><strong>Version:</strong>
        2012.01.30
        <p>This module is intended to be used with the Hide My Ass vpn 
        service. Some HMA servers seem to have a tendency to disconnect 
        without notice (leaving the user exposed).  This script solves the 
        issue by re-launching openvpn if there is a disconnect.</p>
        <p>Currently the script keeps openvpn running and logs server names
        and connection uptime to an xml for file later analysis.  Future 
        additions will hopefully include preferential server selection 
        based on past performance.  The ability to check the connection 
        speed of a server while it is running would also be desirable.</p>
      </p>
      <strong>Change Log:</strong>
      <ul class="nomargin-top">
        <li>
        2012.01.30:
    <ol start="1">
      <li>
        Connects to a new random server every 48 hours
      </li>
      <li>
        Additional error handling
      </li>
      <li>
        Reason for vpn restart is written the xml log
      </li>
    </ol>
        </li>
        <li>
        2012.01.14:
    <ol start="1">
      <li>
        Much refactoring to simplify program flow.
      </li>
      <li>
        Cleaned up program output and logging
      </li>
      <li>
        Bug Fix: Changed server selection so the same server is not called 
        repeatedly if if there is a connection problem.
      </li>
      <li>
        New: XML log now includes reason for VPN disconnection.
      </li>
    </ol>
        </li>
        <li>
        2012.01.12:
    <ol start="1">
      <li>
        Bug Fix: Fixed scrit crashed if unable to check IP at 
        whatismyip.org IP check-in now returns a string instead of -1 if 
        unable to reach URL
      </li>
      <li>
        Bug Fix: Fixed downloading wrong client.cfg file from HMA server
      </li>
    </ol>
        </li>
        <li>
        2012.01.07:
    <ol start="1">
      <li>
        Bug Fix: Fixed str concatenate error where int type would cause 
        exception
      </li>
      <li>
        Bug Fix: Fixed XML logging error
      </li>
    </ol>
        </li>
        <li>
        2012.01.06a:
    <ol start="1">
      <li>
        New: Added xml logging
      </li>
    </ol>
        </li>
        <li>
        2012.01.06:
    <ol start="1">
      <li>
        New: Add exception handler to rand_server(), now returns -1 if 
        server retrieval fails.
      </li>
      <li>
        New: Connection loop restarts if server choice is -1
      </li>
    </ol>
        </li>
        <li>
        2012.01.04:
    <ol start="1">
      <li>
        New: Added status output to text file every 5 minutes
      </li>
    </ol>
        </li>
      </ul>
      <strong>To Do:</strong>
      <ul class="nomargin-top">
        <li>
        Calculate connection speeds if possible
        </li>
        <li>
        Choose server based on best performance
        </li>
      </ul>
</div><!-- ==================== FUNCTIONS ==================== -->
<a name="section-Functions"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Functions</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Functions"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="hma_start-module.html#check_in" class="summary-sig-name">check_in</a>()</span><br />
      Returns the external IP address of the computer using 
      http://whatismyip.org</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="hma_start-pysrc.html#check_in">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="hma_start-module.html#write_log" class="summary-sig-name">write_log</a>(<span class="summary-sig-arg">output</span>,
        <span class="summary-sig-arg">aw</span>=<span class="summary-sig-default"><code class="variable-quote">'</code><code class="variable-string">a</code><code class="variable-quote">'</code></span>,
        <span class="summary-sig-arg">log_file</span>=<span class="summary-sig-default"><code class="variable-quote">'</code><code class="variable-string">vpnlog.txt</code><code class="variable-quote">'</code></span>)</span><br />
      Appends the given output to a log file</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="hma_start-pysrc.html#write_log">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="hma_start-module.html#rand_server" class="summary-sig-name">rand_server</a>(<span class="summary-sig-arg">slist</span>)</span><br />
      Accepts a URL to a list of servers and returns a random item from the
      list.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="hma_start-pysrc.html#rand_server">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="get_time"></a><span class="summary-sig-name">get_time</span>()</span><br />
      Returns a nicely formatted current time</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="hma_start-pysrc.html#get_time">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="hma_start-module.html#write_config" class="summary-sig-name">write_config</a>(<span class="summary-sig-arg">filename</span>,
        <span class="summary-sig-arg">text</span>)</span><br />
      Writes given text to a file.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="hma_start-pysrc.html#write_config">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="time_convert"></a><span class="summary-sig-name">time_convert</span>(<span class="summary-sig-arg">seconds</span>)</span><br />
      Converts time in seconds into d:h:m:s</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="hma_start-pysrc.html#time_convert">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="hma_start-module.html#restart_program" class="summary-sig-name">restart_program</a>()</span><br />
      Restarts the current program.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="hma_start-pysrc.html#restart_program">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="get_version"></a><span class="summary-sig-name">get_version</span>()</span><br />
      Returns the current of the script in the main directory</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="hma_start-pysrc.html#get_version">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="hma_start-module.html#new_version" class="summary-sig-name">new_version</a>(<span class="summary-sig-arg">old_ver</span>)</span><br />
      Checks whether the current script in main directory is a newer 
      version than when the script was first started.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="hma_start-pysrc.html#new_version">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="vpn_running"></a><span class="summary-sig-name">vpn_running</span>(<span class="summary-sig-arg">my_ip</span>,
        <span class="summary-sig-arg">cur_version</span>,
        <span class="summary-sig-arg">duration</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="hma_start-pysrc.html#vpn_running">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="hma_start-module.html#main" class="summary-sig-name">main</a>()</span><br />
      Main function, starts hma script as subprocess.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="hma_start-pysrc.html#main">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<!-- ==================== VARIABLES ==================== -->
<a name="section-Variables"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Variables</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Variables"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="LIST"></a><span class="summary-name">LIST</span> = <code title="'http://vpn.hidemyass.com/vpnconfig/countries.php'"><code class="variable-quote">'</code><code class="variable-string">http://vpn.hidemyass.com/vpnconfig/countries.php</code><code class="variable-quote">'</code></code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="hma_start-module.html#CLCONF" class="summary-name">CLCONF</a> = <code title="'http://vpn.hidemyass.com/vpnconfig/client_config.php?win=1&amp;loc='"><code class="variable-quote">'</code><code class="variable-string">http://vpn.hidemyass.com/vpnconfig/client_config.php</code><code class="variable-ellipsis">...</code></code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="check_ip_url"></a><span class="summary-name">check_ip_url</span> = <code title="'http://whatismyip.org'"><code class="variable-quote">'</code><code class="variable-string">http://whatismyip.org</code><code class="variable-quote">'</code></code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="script_file"></a><span class="summary-name">script_file</span> = <code title="'hma_start.py'"><code class="variable-quote">'</code><code class="variable-string">hma_start.py</code><code class="variable-quote">'</code></code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="txt_log"></a><span class="summary-name">txt_log</span> = <code title="'vpnlog.txt'"><code class="variable-quote">'</code><code class="variable-string">vpnlog.txt</code><code class="variable-quote">'</code></code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="xml_log"></a><span class="summary-name">xml_log</span> = <code title="'vpnlog.xml'"><code class="variable-quote">'</code><code class="variable-string">vpnlog.xml</code><code class="variable-quote">'</code></code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="txt_status"></a><span class="summary-name">txt_status</span> = <code title="'status.txt'"><code class="variable-quote">'</code><code class="variable-string">status.txt</code><code class="variable-quote">'</code></code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="DAY"></a><span class="summary-name">DAY</span> = <code title="86400">86400</code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="hma_start-module.html#openvpn_cmd" class="summary-name">openvpn_cmd</a> = <code title="['openvpn',
 '--config',
 'client.cfg',
 '--auth-user-pass',
 'hmaauth.conf']"><code class="variable-group">[</code><code class="variable-quote">'</code><code class="variable-string">openvpn</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">--config</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">client.cfg</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">--auth-us</code><code class="variable-ellipsis">...</code></code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a name="__package__"></a><span class="summary-name">__package__</span> = <code title="None">None</code>
    </td>
  </tr>
</table>
<p class="indent-wrapped-lines"><b>Imports:</b>
  <span title="os">os</span>,
  <span title="sys">sys</span>,
  <span title="time">time</span>,
  <span title="subprocess">subprocess</span>,
  <span title="urllib2">urllib2</span>,
  <span title="random">random</span>,
  <span title="re">re</span>,
  <a href="logxml-module.html" title="logxml">logxml</a>
</p><br />
<!-- ==================== FUNCTION DETAILS ==================== -->
<a name="section-FunctionDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Function Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-FunctionDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="check_in"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">check_in</span>()</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="hma_start-pysrc.html#check_in">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Returns the external IP address of the computer using 
  http://whatismyip.org</p>
  <dl class="fields">
    <dt>Returns:</dt>
        <dd>IP address as string or 'IP-Unkown' if IP is not determined 
          within 20 seconds.</dd>
  </dl>
</td></tr></table>
</div>
<a name="write_log"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">write_log</span>(<span class="sig-arg">output</span>,
        <span class="sig-arg">aw</span>=<span class="sig-default"><code class="variable-quote">'</code><code class="variable-string">a</code><code class="variable-quote">'</code></span>,
        <span class="sig-arg">log_file</span>=<span class="sig-default"><code class="variable-quote">'</code><code class="variable-string">vpnlog.txt</code><code class="variable-quote">'</code></span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="hma_start-pysrc.html#write_log">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Appends the given output to a log file</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>output</code></strong> (string) - Text to be written to the file</li>
        <li><strong class="pname"><code>aw</code></strong> (strign) - file open parameter (a=append, w=overwrite)</li>
        <li><strong class="pname"><code>log_file</code></strong> (string) - File to write to</li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="rand_server"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">rand_server</span>(<span class="sig-arg">slist</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="hma_start-pysrc.html#rand_server">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Accepts a URL to a list of servers and returns a random item from the 
  list.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>slist</code></strong> (string) - The list of server_list to select from</li>
    </ul></dd>
    <dt>Returns:</dt>
        <dd>A string with the name of the server chosen</dd>
  </dl>
</td></tr></table>
</div>
<a name="write_config"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">write_config</span>(<span class="sig-arg">filename</span>,
        <span class="sig-arg">text</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="hma_start-pysrc.html#write_config">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Writes given text to a file. Will over-write existing text in the 
  file.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>filename</code></strong> (string) - Name of file to write to</li>
        <li><strong class="pname"><code>text</code></strong> (string) - Text to be writtent to the file</li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="restart_program"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">restart_program</span>()</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="hma_start-pysrc.html#restart_program">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Restarts the current program. Note: this function does not return. Any
  cleanup action (like saving data) must be done before calling this 
  function.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="new_version"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">new_version</span>(<span class="sig-arg">old_ver</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="hma_start-pysrc.html#new_version">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Checks whether the current script in main directory is a newer version
  than when the script was first started.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>old_ver</code></strong> (string) - Currently running version of the script</li>
    </ul></dd>
    <dt>Returns:</dt>
        <dd>True if a new version is available to run, otherwise returns 
          false.</dd>
  </dl>
</td></tr></table>
</div>
<a name="main"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">main</span>()</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="hma_start-pysrc.html#main">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Main function, starts hma script as subprocess. Checks for proper VPN 
  connection every 5 minutes and restarts VPN if IP is same as unmasked 
  IP.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== VARIABLES DETAILS ==================== -->
<a name="section-VariablesDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Variables Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-VariablesDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="CLCONF"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <h3 class="epydoc">CLCONF</h3>
  
  <dl class="fields">
  </dl>
  <dl class="fields">
    <dt>Value:</dt>
      <dd><table><tr><td><pre class="variable">
<code class="variable-quote">'</code><code class="variable-string">http://vpn.hidemyass.com/vpnconfig/client_config.php?win=1&amp;loc=</code><code class="variable-quote">'</code>
</pre></td></tr></table>
</dd>
  </dl>
</td></tr></table>
</div>
<a name="openvpn_cmd"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <h3 class="epydoc">openvpn_cmd</h3>
  
  <dl class="fields">
  </dl>
  <dl class="fields">
    <dt>Value:</dt>
      <dd><table><tr><td><pre class="variable">
<code class="variable-group">[</code><code class="variable-quote">'</code><code class="variable-string">openvpn</code><code class="variable-quote">'</code><code class="variable-op">,</code>
 <code class="variable-quote">'</code><code class="variable-string">--config</code><code class="variable-quote">'</code><code class="variable-op">,</code>
 <code class="variable-quote">'</code><code class="variable-string">client.cfg</code><code class="variable-quote">'</code><code class="variable-op">,</code>
 <code class="variable-quote">'</code><code class="variable-string">--auth-user-pass</code><code class="variable-quote">'</code><code class="variable-op">,</code>
 <code class="variable-quote">'</code><code class="variable-string">hmaauth.conf</code><code class="variable-quote">'</code><code class="variable-group">]</code>
</pre></td></tr></table>
</dd>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            >hma_start</th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Mon Jan 30 08:39:41 2012
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
